<include file="Public:head" />
<style>
    tr td{
        text-align: center;
    }
</style>
<style>

    .fangyihang2{
        margin: 20px;
        border: 1px solid #EBEBEB;
        border-radius: 3px;
    }
    .fangyihang2 dt{
        font-size: 15px;
        /* font-weight: bold; */
        padding-left: 45px;
        line-height: 19px;
        background-color: #ECECEC;
        border-radius: 3px;
    }
    .fangyihang2 dd{
        padding-left: 65px;
    }
    dd .checkbox{
        font-weight: normal;
    }
    .form-horizontal .checkbox, .form-horizontal .radio {
        min-height: 35px;
    }
</style>
<body class="overflow-hidden">
<div class="wrapper preload">
    <include file="Public:header" />
    <include file="Public:left" />

    <div class="main-container">
        <div class="padding-md">
            <div class="row">
                <div class="col-sm-12">
                    <div class="page-title">
                        权限设置
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-lg-12">
                    <div class="smart-widget widget-green">
                        <div class="smart-widget-header row ">
                            <span class="smart-widget-option">
                                <span class="refresh-icon-animated">
                                    <i class="fa fa-spinner fa-spin" style="color:#fff"></i>
                                </span>
                                <a href="#" class="widget-toggle-hidden-option">
                                </a>
                                <a href="#" class="widget-collapse-option" data-toggle="collapse">
                                </a>
                                <a href="#" class="widget-refresh-option">
                                </a>
                            </span>
                        </div>
                        <div class="smart-widget-inner table-responsive">
                            <div class="smart-widget-hidden-section">
                                <ul class="widget-color-list clearfix">
                                    <li style="background-color:#20232b;" data-color="widget-dark"></li>
                                    <li style="background-color:#4c5f70;" data-color="widget-dark-blue"></li>
                                    <li style="background-color:#23b7e5;" data-color="widget-blue"></li>
                                    <li style="background-color:#1fb5ac;" data-color="widget-green"></li>
                                    <li style="background-color:#edbc6c;" data-color="widget-yellow"></li>
                                    <li style="background-color:#fbc852;" data-color="widget-orange"></li>
                                    <li style="background-color:#e36159;" data-color="widget-red"></li>
                                    <li style="background-color:#7266ba;" data-color="widget-purple"></li>
                                    <li style="background-color:#f5f5f5;" data-color="widget-light-grey"></li>
                                    <li style="background-color:#fff;" data-color="reset"></li>
                                </ul>
                            </div>
                            <form action="{:U('Unit/writeGroup')}" enctype="application/x-www-form-urlencoded" method="POST" class="form-horizontal auth-form form_button1">
                                <volist name="node_list" id="node" >
                                    <dl class="checkmod fangyihang2">
                                        <dt class="hd">
                                            <label class="checkbox"><input class="auth_rules rules_all" type="checkbox" name="rules[]" value="<?php echo $main_rules[$node['url']] ?>">{$node.title}管理</label>
                                        </dt>
                                        <dd class="bd">
                                            <present name="node['child']">
                                                <volist name="node['child']" id="child" >
                                                    <div class="rule_check">
                                                        <div>
                                                            <label class="checkbox" <notempty name="child['tip']">title='{$child.tip}'</notempty>>
                                                            <input class="auth_rules rules_row" type="checkbox" name="rules[]" value="<?php echo $auth_rules[$child['url']] ?>"/>{$child.title}
                                                            </label>
                                                        </div>
                                                        <notempty name="child['operator']">
                                                            <span class="child_row">
                                                               <volist name="child['operator']" id="op">
                                                                   <label class="checkbox fangyihang" style="margin-left: 20px;" <notempty name="op['tip']">title='{$op.tip}'</notempty>>
                                                                   <input class="auth_rules" type="checkbox" name="rules[]"
                                                                          value="<?php echo $auth_rules[$op['url']] ?>"/>{$op.title}
                                                                   </label>
                                                               </volist>
                                                            </span>
                                                        </notempty>
                                                    </div>
                                                </volist>
                                            </present>
                                        </dd>
                                    </dl>
                                </volist>
                                <input type="hidden" name="id" value="{$this_group.id}" />
                                <button type="submit" class="action-button ajax-post"  target-form="form_button1">确 定</button>
                                <button class="action-button" onclick="javascript:history.back(-1);return false;">返 回</button>
                            </form>

                        </div><!-- ./smart-widget-inner -->
                    </div><!-- ./smart-widget -->
                </div><!-- ./col -->
            </div><!-- ./row -->
        </div><!-- ./padding-md -->
    </div><!-- /main-container -->
    <include file="Public:foot" />
</div><!-- /wrapper -->
<include file="Public/base_fc" />
<a href="#" class="scroll-to-top hidden-print"><i class="fa fa-chevron-up fa-lg"></i></a>
</body>
</html>
<block name="script">
    <script type="text/javascript" src="__PUBLIC__/js/qtip/jquery.qtip.min.js"></script>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/js/qtip/jquery.qtip.min.css" media="all">
    <script type="text/javascript" charset="utf-8">
        $(function(){
            var rules = [{$this_group.rules}];
            $('.auth_rules').each(function(){
                if( $.inArray( parseInt(this.value,10),rules )>-1 ){
                    $(this).prop('checked',true);
                }
                if(this.value==''){
                    $(this).closest('span').remove();
                }
            });
        })
        //全选节点
        $('.rules_all').on('change',function(){
            $(this).closest('dl').find('dd').find('input').prop('checked',this.checked);
        });
        $('.rules_row').on('change',function(){
            $(this).closest('.rule_check').find('.child_row').find('input').prop('checked',this.checked);
        });

        $('.checkbox').each(function(){
            $(this).qtip({
                content: {
                    text: $(this).attr('title'),
                    title: $(this).text()
                },
                position: {
                    my: 'bottom center',
                    at: 'top center',
                    target: $(this)
                },
                style: {
                    classes: 'qtip-dark',
                    tip: {
                        corner: true,
                        mimic: false,
                        width: 10,
                        height: 10
                    }
                }
            });
        });

        $('select[name=group]').change(function(){
            location.href = this.value;
        });

        $(function () {
            highlight_nav2('{:U("Unit/user_group")}');
        })
    </script>
</block>


